<?php
class Task extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		$this->load->model('Util');
		$this->load->model('TaskManager');
		$this->load->model('DatabaseManager');
		$this->load->model('SessionManager');
		$this->load->helper(array('form', 'url'));
	}
	public function getTaskList(){
		$data=$this->TaskManager->get_task_list();
		echo json_encode($data);
	}
	public function getTaskListByUsername(){
		$username=$_REQUEST['username'];
		$sessionId=$_REQUEST['sessionId'];
		$data=$this->TaskManager->get_task_list_by_username($username,$sessionId);
		echo json_encode($data);
	}
	public function getReceiveTaskList(){
		$username=$_REQUEST['username'];
		$sessionId=$_REQUEST['sessionId'];
		$data=$this->TaskManager->get_receive_task_list($username,$sessionId);
		echo json_encode($data);
	}
	public function releaseTask(){
		$username=$_REQUEST['username'];
		$sessionId=$_REQUEST['sessionId'];
		$data=$_REQUEST['data'];
		$data=$this->TaskManager->release_task($username,$sessionId,$data);
		echo json_encode($data);
	}
	public function getTaskDetail(){
		$id=$_REQUEST['id'];
		$username=$_REQUEST['username'];
		$sessionId=$_REQUEST['sessionId'];
		$data=$this->TaskManager->get_task_detail($username,$sessionId,$id);
		echo json_encode($data);
	}
	public function receiveTask(){
		$id=$_REQUEST['id'];
		$username=$_REQUEST['username'];
		$sessionId=$_REQUEST['sessionId'];
		$data=$this->TaskManager->receive_task($username,$sessionId,$id);
		echo json_encode($data);
	}
	public function finishTask(){
		$id=$_REQUEST['id'];
		$username=$_REQUEST['username'];
		$sessionId=$_REQUEST['sessionId'];
		$data=$this->TaskManager->finish_task($username,$sessionId,$id);
		echo json_encode($data);
	}
	public function evaluteTask(){
		$id=$_REQUEST['id'];
		$username=$_REQUEST['username'];
		$sessionId=$_REQUEST['sessionId'];
		$rating=$_REQUEST['rating'];
		$data=$this->TaskManager->evalute_task($username,$sessionId,$id,$rating);
		echo json_encode($data);
	}
	public function deleteTask(){
		$id=$_REQUEST['id'];
		$username=$_REQUEST['username'];
		$sessionId=$_REQUEST['sessionId'];
		$data=$this->TaskManager->delete_task($username,$sessionId,$id);
		echo json_encode($data);
	}
	public function test(){
		$data=$this->TaskManager->get_task_list_by_username('12946137',$sessionId);
		echo json_encode($data);
	}
}